package com.niit.drugsmanager.entity;

import com.niit.drugsmanager.entity.embeddable.NoticeStatusId;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@IdClass(NoticeStatusId.class)
@Table(name = "notice_status")
@NoArgsConstructor
@AllArgsConstructor
public class NoticeStatus {

    @Id
    @Column(name = "uid")
    private Long uid;

    @Id
    @Column(name = "nid")
    private Long nid;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "nid", referencedColumnName = "id",
            foreignKey = @ForeignKey(name = "notice_status_notice"),
            insertable = false, updatable = false)
    private Notice notice;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "uid", referencedColumnName = "id",
            foreignKey = @ForeignKey(name = "notice_status_user"),
            insertable = false, updatable = false)
    private User user;

    @Column(name = "read_time")
    private LocalDateTime readTime;

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    public Long getNid() {
        return nid;
    }

    public void setNid(Long nid) {
        this.nid = nid;
    }

    public Notice getNotice() {
        return notice;
    }

    public void setNotice(Notice notice) {
        this.notice = notice;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public LocalDateTime getReadTime() {
        return readTime;
    }

    public void setReadTime(LocalDateTime readTime) {
        this.readTime = readTime;
    }
}
